﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfWordsLearner.Views
{
	/// <summary>
	/// Interaction logic for ExportView.xaml
	/// </summary>
	public partial class ExportView : Window
	{
		public ExportView()
		{
			InitializeComponent();
		}

		private void btnExport_Click(object sender, RoutedEventArgs e)
		{
			if (!string.IsNullOrEmpty(txtPath.Text))
			{
				ExportManager export = new ExportManager(txtPath.Text);
				export.Completed += new EventHandler(export_Completed);
				export.RunExport();
			}
		}

		void export_Completed(object sender, EventArgs e)
		{
			Dispatcher.BeginInvoke(new Action(() =>
			{
				this.Close();
				MessageBox.Show("Operation completed successfully");
			}), System.Windows.Threading.DispatcherPriority.Normal);
		}

		private void btnCancel_Click(object sender, RoutedEventArgs e)
		{
			this.Close();
		}
	}
}
